model{
  for (i in 1:n.polls) {
    y[i] ~ dnorm(mu1[i], nu1[i])
    mu1[i] <- alpha[weekid[i]] + delta[house[i]] + lambda * cue[i]
    nu1[i] <- pow((pow(tau[house[i]], design[i]) * sqrt(mu1[i] * (1 - mu1[i]) / n.obs[i])), -2)
  }
  alpha[1] ~ dunif(lo, up)
  for (t in 2:n.weeks) {
    alpha[t] ~ dnorm(alpha.star[t], omega.star)
    alpha.star[t] <- alpha[t - 1] + kappa * reshuffle[t]
  }
  for (h in 1:10) {
    delta[h] <- delta.star[h]
  }
  delta[11] <- -delta.star[1] - delta.star[2] - delta.star[3] - delta.star[4] - 
    delta.star[5] - delta.star[6] - delta.star[7] - delta.star[8] - 
    delta.star[9] - delta.star[10]
  for (h in 1:10) {
    delta.star[h] ~ dnorm(0, 0.01)
  }
  omega.star <- pow(omega, -2)
  omega ~ dunif(0, 100)
  for (h in 1:11) {
    tau[h] ~ dunif(0, 100)
  }
  kappa ~ dnorm(0, 0.01)
  lambda ~ dnorm(0, 0.01)
}